<template>
  <div class="step-five">
    <div class="main">
      <reservePlan :plan="routeParam" />
    </div>
    <div class="btn-group">
      <el-button style="width: 300px" @click="goUp">上一步</el-button>
      <el-button type="success" style="width: 300px" @click="goNext"
        >完成</el-button
      >
    </div>
  </div>
</template>

<script>
import reservePlan from "@/components/createPlan/reservePlan";
import { userschemestrategy, scheme } from "@/api/decision/task";
export default {
  data() {
    return {
      param: null,
      routeParam:''
    };
  },
  computed: {
    userID() {
      return this.$store.state.user.userId
    }
  },
  created() {
    const planParam = JSON.parse(localStorage.getItem('planParam'))
    if (planParam) {
      this.routeParam = planParam
    }
  },
  components: {
    reservePlan: reservePlan,
  },
  methods: {
    goUp() {
      this.$router.go(-1);
    },
    goNext() {
      let param = {}
      param['userId'] = this.userID
      param['schemeId'] =  this.routeParam.taskId
      param['strategyIds'] = JSON.parse(sessionStorage.getItem('strategyIds'))
      userschemestrategy(param).then((response) => {
        let params = {}
        params['schemeName'] =  this.routeParam.taskName
        params['taskId'] =  this.routeParam.taskId
        scheme(params).then((response) => {
          
          this.$router.push("/decision/plan/task");
        });
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.step-five {
  padding: 10px;
  width: 100%;
  .main {
    .title {
      text-align: center;
      font-size: 18px;
      font-weight: 600;
    }
  }
}
.btn-group {
  display: flex;
  margin-top: 15px;
  justify-content: center;
}
</style>
